import React from "react";
import { getTableProps } from "components/searchTable/SearchTable.jsx";
import {getMenuRouter, getPageOperate} from "components/layouts/menuFn";


export default class Base extends React.Component {
  getMenuRouter = getMenuRouter.bind(this);

  getPageOperate = getPageOperate.bind(this);

  getOprateDisable = (type) => {
    const {
      location: { pathname = "" },
      menuDataList,
      resourceList,
    } = this.props;
    const res = this.getPageOperate(type, pathname, menuDataList, resourceList);
    return res;
  };

  getFormConfig = () => {
    return [
      { label: "流程实例ID", key: "processInstanceIds" },
      { label: "任务ID", key: "taskId" },
      { label: "变量名称",   key: "name" },
    ];
  };

  getTableColumns = () => {
    return [
      {
        title: "序号",
        dataIndex: "Id",
        render: (value, record, index) => {
          const {
            page: { pageNum, pageSize },
          } = this.state;
          return (pageNum - 1) * pageSize + index + 1;
        },
      },
      { title: "流程实例ID", dataIndex: "processInstanceId" },
      { title: "任务ID", dataIndex: "taskId" },
      { title: "变量名称", dataIndex: "name" },
      { title: "变量类型", dataIndex: "type" },
      { title: "变量值", dataIndex: "value" },
    ];
  };

  getAntTableProps = () => {
    const {
      page: { pageNum, pageSize },
    } = this.state;
    const { historicVariableList, loading } = this.props;
    const { datas = [], totalCount } = historicVariableList;
    return getTableProps({
      rowKey: "Id",
      columns: this.getTableColumns(),
      dataSource: datas,
      loading: loading.effects["FlowMonitor/historicVariableList"],
      pagination: {
        current: pageNum,
        pageSize,
        total: totalCount,
        onChange: this.handlePageChange,
        onShowSizeChange: this.handlePageChange,
      },
    });
  };
}
